package com.example.yrdev.ordering_system.Utils;

import java.util.ArrayList;

/**
 * Created by luke on 11/3/17.
 */

public class MICardUtils {

    public static String convertedToDecimal(String hex){

        Long temp=Long.parseLong(hex,16);

        return String.valueOf(temp);


    }

    public static String checkContentLength(String content,int maxLen){
        ArrayList<String> arrayList=new ArrayList<>();

        if (content.length()%2==0)
        {
            for (int i=0;i<content.length();i=i+2){

                arrayList.add(content.substring(i,i+2));

            }

        }else {
            StringBuilder temp=new StringBuilder();

            while (content.length()%2==0){
                temp.append("0");
                content=temp.toString()+content;

            }
            for (int i=0;i<content.length();i=i+2){

                arrayList.add(content.substring(i,i+2));

            }

        }
        GlobalFunction.printTextByTag("dasdas");

        while (arrayList.size()!=maxLen){
            arrayList.add(0,"00");
        }
        StringBuilder res=new StringBuilder();
        for (String string:arrayList){
            res.append(string);

        }
        return res.toString();

    }

}
